/**
 * 
 */
package com.google.code.cisx.web;

import java.util.List;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.DontValidate;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.google.code.cisx.model.project.Project;
import com.google.code.cisx.store.StoreService;
import com.google.code.cisx.store.api.StoreException;
import com.google.code.cisx.store.jpa.query.ProjectQuery;

/**
 * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
 * @version $Id: QueryProjectsActionBean.java 259 2008-11-29 13:18:52Z rahul.thakur.xdev $
 * @since 1.0
 */
public class QueryProjectsActionBean extends CommonActionBean implements ActionBean {

  private static final Log log = LogFactory.getLog(QueryProjectsActionBean.class);

  /**
   * List of ProjectGroups to display.
   */
  private List<Project> projects;

  /**
   * @return the projectGroups
   */
  public List<Project> getProjects() {
    return projects;
  }

  @DefaultHandler
  @DontValidate
  public Resolution view() {
    try {
      this.projects = StoreService.query(Project.class, new ProjectQuery<Project>(), 0, 100);
      log.info(String.format("Obtained %s %s instances for display.", this.projects.size(), Project.class
          .getSimpleName()));
    } catch (StoreException e) {
      e.printStackTrace();
    }
    return new ForwardResolution("/searchProjects.jsp");
  }
}
